package net.zjitc.tree;

import net.domain.Person;

import java.util.Comparator;
import java.util.TreeSet;

public class Test {
    public static void main(String[] args) {
       /* TreeSet<Integer> set = new TreeSet<>(); //有序 唯一的
        set.add(12);
        set.add(19);
        set.add(87);
        set.add(9);
        set.add(3);
        set.add(19);

*/

       //排序的规则有没有 ？
        Person p1 = new Person(20,"ab");
        Person p2 = new Person(18,"abb");
        Person p3 = new Person(21,"aab");
        TreeSet<Person> set = new TreeSet<>(new Comparator<Person>() {
            @Override
            public int compare(Person o1, Person o2) {
                return o1.age - o2.age;
            }
        });
        set.add(p1);
        set.add(p2);
        set.add(p3);

        System.out.println(set);
    }
}
